package com.turman.plyopengl.programs

import android.content.Context
import android.opengl.GLES20
import com.turman.plyopengl.R

class PlyShaderProgram(context: Context) :
    ShaderProgram(context, R.raw.ply_vertex_shader, R.raw.ply_fragment_shader) {
    private val uMatrixLocation: Int = getUniformLocation(U_MATRIX)
    val aPositionLocation: Int = getAttribLocation(A_POSITION)
    val aColorLocation: Int = getAttribLocation(A_COLOR)
    private val pointSizeLocation:Int = getAttribLocation(POINT_SIZE)

    fun setUniforms(matrix: FloatArray) {
        GLES20.glUniformMatrix4fv(uMatrixLocation, 1, false, matrix, 0)
        GLES20.glVertexAttrib1f(pointSizeLocation, 1f)
    }

    companion object {
        private const val U_MATRIX = "u_Matrix"
        private const val A_POSITION = "a_Position"
        private const val A_COLOR = "a_Color"
        private const val POINT_SIZE = "point_Size"
    }
}